package com.voip;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Toast;

import com.voipAgent.SipAgent;
import com.voipAgent.SipAgent.SipEventListener;

public class MainActivtiy extends Activity implements SipEventListener{
	private SipAgent sipAgent;
//	private XmppAgent xmppAgent;
	private Context context;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		sipAgent=SipAgent.getInstance(this, this);
		
		//微话
		/*String sipServer="117.122.192.155:5080";
		String sipDomain="sip.95voice.com";
		int sipPort = 5080;
		
		String sipSlaveServer = "114.251.39.18:5080";
		String sipSlaveDomain = "sip2.95voice.com";
		int sipSlavePort = 6060;*/
		
		//微话+
		String sipServer="45.62.101.19:5060";
		String sipDomain="45.62.101.19";
		int sipPort = 5060;

        /*String sipServer="117.122.192.150:6020";
		String sipDomain="117.122.192.150";
		int sipPort = 6020;*/
		
		String sipSlaveServer = "45.62.101.19:5060";
		String sipSlaveDomain = "45.62.101.19";
		int sipSlavePort = 5060;
		
		/*public static String MASTER_SERVER = "210.13.82.206:5060";
		public static String MASTER_SERVERDOMAIN = "as1.shangkebao.com";
		public static int MASTER_SERVERPORT = 5060;

		public static String SLAVE_SERVER = "58.32.186.228:5060";
		public static String SLAVE_SERVERDOMAIN = "as2.shangkebao.com";
		public static int SLAVE_SERVERPORT = 5060;*/
		
		sipAgent.setConfig(sipServer,sipDomain,sipPort,sipSlaveServer,sipSlaveDomain,sipSlavePort);
		sipAgent.start();
		//sipAgent.login("95013770106814", "670B14728AD9902AECBA32E22FA4F6BD");//95013770106783*/

//		sipAgent.login("201000002013", "4795467498009740");//95013770106783*/

        sipAgent.login("1001", "1234");//95013770106783*/
		
//		xmppAgent = XmppAgent.getInstance(this, this);
//		xmppAgent.start();
//		xmppAgent.login("95013770106814", "670B14728AD9902AECBA32E22FA4F6BD");
		
		findViewById(R.id.btn).setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				//sipAgent.callOut("9501388");//95013770106814可以，18803210314不可以//18811321040
                sipAgent.login("201000001423", "6941939683374320");//950138006447*/
                //sipAgent.login("1001", "1234");//95013770106783*/
				//sipAgent.callOut("1002");
			}
		});
	}
	@Override
	public void onSipLoginSuccess() {
		// TODO Auto-generated method stub
		Toast.makeText(context, "onSipLoginSuccess", Toast.LENGTH_SHORT).show();
	}
	@Override
	public void onSipLoginError(int errorcode) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void onSipCallRing() {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void onSipCallOK() {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void onSipCallEnd(int code) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void onSipKick() {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void isSipOnline(boolean isOnline) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void onSipUpdateStatus() {
		// TODO Auto-generated method stub
		
	}



}
